<template>
  <section class="todoapp">
    <!-- 头部部分 -->
    <header class="header">
      <h1>todos</h1>
      <input
        class="new-todo"
        placeholder="请输入任务名称"
        autofocus
        v-model.trim="str"
        @keyup.enter="addList"
      />
    </header>
  </section>
</template>

<script>
export default {
  name: 'odosHeader',
  components: {},
  props: {},
  data() {
    return {
      str:''
    }
  },
  computed: {},
  watch: {},
  created() {},
  methods: {
    addList(){
      if(this.str==='')return alert ('输入框不能为空哦~')
      this.$emit("addList",this.str)
      this.str=''
    }
  },
}
</script>

<style scoped></style>
